package spring.factorybean;

import org.springframework.beans.factory.FactoryBean;
import spring.bean.Car;

/**
 * @Date 2021/5/17 14:47
 * @Author WangLinBao
 * @Description
 */
public class CarFactoryBean implements FactoryBean {
    private String carInfo;

    public void setCarInfo(String carInfo){
        this.carInfo = carInfo;
    }
    @Override
    public Object getObject() throws Exception {
        Car car = new Car();
        String[] split = carInfo.split(",");
        car.setMaxSpeed(200);
        car.setColor(split[0]);
        return car;
    }

    @Override
    public Class<?> getObjectType() {
        return Car.class;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
